package com.llxwz.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

//@Component
//@Aspect
public class AlphaAspect {

    //* 方法返回值
    //com.zb.service 包名
    //* 类
    //* 方法
    //(..)参数
    @Pointcut("execution(* com.llxwz.service.*.*(..))")
    public void pointcut() {

    }

    //连接点开始
    @Before("pointcut()")
    public void before() {
        System.out.println("before");
    }
    //连接点结束
    @After("pointcut()")
    public void after() {
        System.out.println("after");
    }
    //返回值之后
    @AfterReturning("pointcut()")
    public void afterRetuning() {
        System.out.println("afterRetuning");
    }
    //抛异常之后
    @AfterThrowing("pointcut()")
    public void afterThrowing() {
        System.out.println("afterThrowing");
    }
    //连接点前后
    @Around("pointcut()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("around before");
        Object obj = joinPoint.proceed();//目标组件(Service方法)返回值
        System.out.println("around after");
        return obj;
    }

}
